home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16814 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: news.sprintlink.net!datalytics!usenet
  2. From: Dellis Hines <dellish@datalytics.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: C++ guru sought ...
  5. Date: Thu, 11 Apr 1996 16:52:26 -0400
  6. Organization: Datalytics, Inc
  7. Message-ID: <316D710A.4B6C@datalytics.com>
  8. References: <316CB5B5.41C6@cs.york.ac.uk>
  9. NNTP-Posting-Host: 204.62.224.100
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 3.0B2 (WinNT; I)
  14.  
  15. John Kennedy wrote:
  16. > Hi there,
  17. > I have an interesting C++ problem that I was wondering if any guru out
  18. > there knows the answer to....
  19. > I am trying to create a template class that saves or reads data to/from
  20. > a file.  This is not a problem for numeric data as fstream can cope with
  21. > this no problem.  The problem I have is that when the template type is a
  22. > string I have to create the space to store the data in. The only way I
  23. > can see of doing this is to use a case statement in the template
  24. > function but this is then removing all purpose of creating a template in
  25. > the first place.
  26. > Does anyone know a way around this problem ?
  27. > John Kennedy
  28. > johnk@cs.york.ac.uk
  29.  
  30. Try reading a book called 'Advanced C++ Programming Styles and Idioms' by James Coplien of 
  31. Bell Labs.  In it he elucidates a number of programming styles to get around problems 
  32. like this, which just about require a 'virtual constructor'.  I have successfully used one 
  33. of his idioms (the 'envelope and letter' idiom) to get around just such a problem on several 
  34. projects.
  35.  
  36. This is a very good book that presents solutions to a segment of the language rarely tackled 
  37. by many book writers, that of introducing runtime flexibility without sacrificing type 
  38. safety and maintainability.  I can recommend it without hesitation.
  39.  
  40. Regards,
  41. Dellis Hines
  42. dellish@datalytics.com
  43.